using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ProductKeysWin
{
    /// <summary>
    /// Interaction logic for AddDialog.xaml
    /// </summary>

    public partial class AddDialog : System.Windows.Window
    {
        private ProductKey _Key;

        public ProductKey Key
        {
            get
            {
                if (_Key == null)
                {
                    return _Key;
                }
                else if (!String.IsNullOrEmpty(_Key.Name) && !String.IsNullOrEmpty(_Key.Key))
                {
                    return _Key;
                }
                else
                {
                    return null;
                }
            }
        }

        public AddDialog()
        {
            InitializeComponent();
            ShowInTaskbar = false;
            WindowStartupLocation = WindowStartupLocation.CenterOwner;
        }

        protected void WindowLoaded(object sender, RoutedEventArgs e)
        {
            _Key = new ProductKey();
            DataContext = _Key;
            Background = new SolidColorBrush(SystemColors.ControlColor);
            _Key.DateClaimed = DateTime.Now;
        }

        protected void CancelButtonClick(object sender, RoutedEventArgs e)
        {
            _Key = null;
            this.Close();
        }

        protected void OkButtonClick(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

    }
}